package com.wika.basics.dialog

import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import com.wika.basics.base.BaseDialog
import com.wika.basics.databinding.DialogLoadingBinding
import com.wika.framework.manager.AppManager

/**
 *@Description: 加载框
 *@Date: 2024/7/26 16:04
 *@Author: WangWeiShuo
 */
class LoadingDialog {
    class Builder(
        context: Context
    ) : BaseDialog.Builder<Builder>(context) {
        private val mBinding: DialogLoadingBinding = DialogLoadingBinding.inflate(LayoutInflater.from(context))

        init {
            setContentView(mBinding.root)
            val width = AppManager.getInstance(context).getScreenWidthPx()
            setWidth((width * 0.6).toInt())
//            setHeight((width * 0.5).toInt())
            setAnimStyle(BaseDialog.AnimStyle.IOS)
            setGravity(Gravity.CENTER)
        }

        fun showLoading(msg: String?){
            mBinding.tvLoading.text = msg
            show()
        }

        fun dismissLoading(){
            dismiss()
        }
    }
}